package com.ciaojian.core.service;

import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
import com.baomidou.mybatisplus.core.mapper.BaseMapper;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import com.ciaojian.core.mapper.ActivityPopMapper;
import com.ciaojian.core.model.ActivityPop;

import java.util.Date;

/**
 * 活动弹窗 service
 *
 * @author Atlakyn
 */
public abstract class ActivityPopService<M extends BaseMapper<T>, T> extends ServiceImpl<ActivityPopMapper, ActivityPop> {

    public ActivityPop getEffectPop(Integer id) {
        QueryWrapper<ActivityPop> queryWrapper = new QueryWrapper<>();
        queryWrapper.eq("state", 1)
                .gt("end_time", new Date())
                .eq("id", id);
        return new ActivityPop().selectOne(queryWrapper);
    }

    public Boolean checkLabelContains(String label, String labelStrList) {
        Integer integer = baseMapper.checkLabelContains(label, labelStrList);
        // 大于 0 表示包含
        return integer > 0;
    }
}
